package jhc.cn.servlet;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.dbutils.QueryRunner;

import jhc.cn.AirSpace;
import jhc.cn.db.ArticleDao;

/**
 * Servlet implementation class ArticleDel
 */
@WebServlet("/del.do")
public class ArticleDel extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String sid = request.getParameter("id");
		int id;
		id = Integer.valueOf(sid).intValue();
		
		QueryRunner runner = (QueryRunner) request.getServletContext().getAttribute(AirSpace.KET_QUERY_RUNNER);
		try {
			ArticleDao.del(runner, id);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		response.sendRedirect("./list.do");
	}

}
